<template>
    <div class="Notice">
        <div class="header"><img class="return_img" src="@/assets/Return.png" style="width:.23rem;height:.4rem;" v-on:click="back()">会议须知预览</div>       
        <div class="content">
            <div class="hed">
                <p>{{year}}&nbsp;&nbsp;{{publish.theme}}</p>
                <span>{{publish.province}}{{publish.city}}</span>
            </div>
             <div class="time">
                <div class="title">
                  <span>会</span><span>议</span><span>开</span><span>始</span><span>时</span><span>间：</span>
                </div>
                <span class="time_cont">{{format(publish.startTime,'yyyy-MM-dd hh:mm') }}</span>
            </div>
            <div class="time">
                <div class="title">
                  <span>会</span><span>议</span><span>结</span><span>束</span><span>时</span><span>间：</span>
                </div>
                <span class="time_cont">{{format(publish.endTime,'yyyy-MM-dd hh:mm') }}</span>
            </div>
            <div class="address">
                <div class="title">
                  <span>会</span><span>议</span><span>地</span><span>址：</span>
                </div>
                <span class="address_hove">{{publish.address}}</span>
                <span class="see_map" @click="showPlugin">查看地图</span>
            </div>
            <div v-transfer-dom>
              <x-dialog v-model="showDialogStyle" hide-on-blur :dialog-style="{'max-width': '100%', width: '100%', height: '100%', 'background-color': 'transparent'}">
                <div id="allmap" ref="allmap" style="height:100%;" ></div>
                <div class="map_close" @click="hidePlugin"><img src="../../../assets/close.png" alt=""></div>
              </x-dialog>
            </div>
            <div class="detail">
                <p class="detail_cont" v-html="publish.content"></p>
            </div>
            <div class="footer">
                <x-button type="primary" @click.native="btn" class="btn">修改</x-button>
            </div>
        </div>
    </div>
</template>
<script>
import { XButton, XDialog, TransferDomDirective as TransferDom } from "vux";
import { getMeetingPublish } from "@/service/meeting.js";
import { format } from "@/service/util.js";
export default {
  directives: {
    TransferDom
  },
  components: { XButton, XDialog, TransferDom },
  data() {
    return {
      publish: "",
      format: format,
      flg: false,
      showDialogStyle: false,
      mOrderId: "",
      year: "",
      android: true //区分安卓入口字段
    };
  },
  created() {
    var date = new Date();
    this.year = date.getFullYear();
  },
  methods: {
    _getMeetingPublish() {
      var data = {
        mOrderId: this.mOrderId
      };
      getMeetingPublish(data).then(res => {
        this.publish = res.data.publish;
        localStorage.setItem("publish", JSON.stringify(this.publish));
        this.map();
      });
    },
    btn() {
      let id = this.$route.query.id;
      if (id) {
        sessionStorage.setItem("android", this.android);
        this.$router.push({
          path: "/my/Meeting/Notice_edit",
          query: { id: id }
        });
      } else {
        this.$router.push("/my/Meeting/Notice_edit");
      }
      sessionStorage.setItem("mOrderId", this.mOrderId);
    },
    map() {
      var map = new BMap.Map("allmap");
      var point = new BMap.Point(
        parseFloat(this.publish.lon),
        parseFloat(this.publish.lat)
      );
      map.centerAndZoom(point, 14);
      map.panBy(200, 365); //改变标点位置
      var marker = new BMap.Marker(point); // 创建标注
      map.addOverlay(marker); // 将标注添加到地图中

      /// map.setCurrentCity("长沙"); // 仅当设置城市信息时，MapTypeControl的切换功能才能可用
    },
    showPlugin() {
      this.showDialogStyle = true;
    },
    hidePlugin() {
      this.showDialogStyle = false;
    },
    back() {
      let id = this.$route.query.id;
      if (id) {
        window.android.goBack();
      } else {
        this.$router.push("/my/Meeting/MeetingCode_first");
      }
    }
  },
  mounted() {
    this.mOrderId = this.$route.query.id
      ? this.$route.query.id
      : sessionStorage.getItem("mOrderId");
    this._getMeetingPublish();
  }
};
</script>
<style lang="less">
.detail_cont {
  img {
    max-width: 100%;
  }
}
</style>
<style scoped lang="less">
.Notice {
  .header {
    height: 0.88rem;
  }

  .content {
    margin-top: 0.1rem;
    background: #fff;

    .hed {
      height: 1.36rem;
      padding: 0.26rem 0;
      text-align: center;
      border-bottom: 1px solid rgba(243, 243, 243, 1);
      p {
        height: 0.39rem;
        font-size: 0.36rem;
        font-family: PingFang-SC-Medium;
        color: rgba(38, 38, 38, 1);
        line-height: 0.33rem;
        margin-bottom: 0.14rem;
      }
      span {
        height: 0.28rem;
        font-size: 0.3rem;
        font-family: PingFang-SC-Medium;
        color: rgba(154, 154, 154, 1);
        line-height: 0.28rem;
      }
    }
    .time,
    .address {
      width: 7.25rem;
      margin-left: 0.25rem;
      height: 0.9rem;
      line-height: 0.9rem;
      font-size: 0.3rem;
      color: rgba(38, 38, 38, 1);
      border-bottom: 1px solid rgba(243, 243, 243, 1);

      display: -webkit-box;
      display: -webkit-flex;
      display: -ms-flexbox;
      display: flex;
      .address_hove {
        width: 2.8rem;
        display: inline-block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .title {
        width: 2.1rem;
        // display: inline-block;

        white-space: nowrap;
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack: justify;
        -webkit-justify-content: space-between;
        -ms-flex-pack: justify;
        justify-content: space-between;
        span {
          // display: block;
        }
      }
      .time_cont {
        width: 5rem;
        display: inline-block;
      }
      .time_fot {
        img {
          width: 0.35rem;
          height: 0.38rem;
        }
      }
      .see_map {
        background: #8239d1;
        color: #fff;
        height: 0.6rem;
        display: inline-block;
        line-height: 0.6rem;
        width: 1.5rem;
        text-align: center;
        border-radius: 10%;
        margin-top: 0.15rem;
      }
    }
    .detail {
      width: 7rem;
      min-height: 6rem;
      border: 1px solid rgba(221, 221, 221, 1);
      border-radius: 0.1rem;
      margin: 0 auto;
      margin-top: 0.27rem;
      padding: 0.11rem 0.19rem 0.15rem 0.17rem;
      p {
        margin-bottom: 0.19rem;
        font-size: 0.3rem;
        word-wrap: break-word;
      }
    }
    .footer {
      height: 1.4rem;
      line-height: 0.8rem;
      margin: 0.59rem 0.25rem 0 0.25rem;
      .met_btn {
        margin-right: 0.3rem;
      }
      .btn {
        width: 7rem;
        height: 0.8rem;
        line-height: 0.8rem;
        background: rgba(135, 42, 145, 1) !important;
        border-radius: 0.08rem !important;
        display: inline-block;
      }
    }
  }
}
.content div:nth-child(1) {
  top: 50%;
  left: 50%;
}
.map_close {
  position: fixed;
  top: 0.1rem;
  right: 0.1rem;
  background: #8239d1;
  border-radius: 50%;
  padding: 0.1rem;
}
</style>
